package com.eastcom.dataquality.core.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

import com.eastcom.dataquality.core.module.Atom_MsgSub;

public class MsgSubDao extends JdbcDaoSupport implements RowMapper<Atom_MsgSub>{

	public List<Atom_MsgSub> findAll(){
		String sql="select * from qa_msgSub";
		List<Atom_MsgSub> results=this.getJdbcTemplate().query(sql, this);
		return results;
	}
	
	public Atom_MsgSub mapRow(ResultSet rs, int rowNum) throws SQLException {
		Atom_MsgSub sub=new Atom_MsgSub();
		sub.setId(rs.getString("id"));
		sub.setDataset_id(rs.getString("dataset_id"));
		sub.setSubType(rs.getInt("subType"));
		sub.setEmail(rs.getString("email"));
		return sub;
	}

	public List<String> selectEmailsByType(int type){
		String sql="select email from qa_msgSub where subType="+type;
		List<String> results=this.getJdbcTemplate().queryForList(sql, String.class);
		return results;
	}
}
